package demo3.demo4;

import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.PropertySource;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

//@Component
//@Scope("prototype")
//@PropertySource("classpath:config.properties")
public class Person implements InitializingBean, DisposableBean {
    private String name;
    private int age;
    public Person(){
        System.out.println(name);
        System.out.println("无参构造方法");
    }
@Value("${Person.name}")
    public void setName(String name) {
        System.out.println("setName()方法");
        this.name = name;
        System.out.println(name);
    }
    @Value("${Person.age}")
    public void setAge(int age) {
        System.out.println("setAge()方法");
        this.age = age;
        System.out.println(age);
    }
    public void play(){

    }
   @Override
    public void afterPropertiesSet() throws Exception {
        System.out.println("afterPropertiesSet()方法");
    }

    @Override
    public String toString() {
        return "Person{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }

    @Override
    public void destroy() throws Exception {
        System.out.println("destory()方法");
    }
}
